Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
---
 Signed-off-by: Peter Kriens <[email protected]>

Signed-off-by: Peter Kriens <[email protected]>
  • Loading branch information
pkriens committed Nov 21, 2023
1 parent 055d795 commit 9e4ce34
Show file tree
Hide file tree
Showing 21 changed files with 1,421 additions and 74 deletions.
2 changes: 0 additions & 2 deletions biz.aQute.bnd.api/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
eclipse.preferences.version=1
encoding//src/biz/aQute/bnd/facade/api/package-info.java=UTF-8
encoding/<project>=UTF-8
encoding/bnd.bnd=UTF-8
2 changes: 2 additions & 0 deletions biz.aQute.bnd.api/.settings/org.eclipse.core.runtime.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
505 changes: 504 additions & 1 deletion biz.aQute.bnd.api/.settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions biz.aQute.bnd.api/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=false
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=false
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_functional_interfaces=true
cleanup.convert_to_enhanced_for_loop=true
cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
cleanup.correct_indentation=false
cleanup.format_source_code=false
cleanup.format_source_code_changes_only=false
cleanup.insert_inferred_type_arguments=false
cleanup.lazy_logical_operator=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=false
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=false
cleanup.merge_conditional_blocks=false
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true
cleanup.number_suffix=true
cleanup.objects_equals=true
cleanup.organize_imports=false
cleanup.precompile_regex=true
cleanup.push_down_negation=false
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true
cleanup.remove_redundant_modifiers=true
cleanup.remove_redundant_semicolons=true
cleanup.remove_redundant_type_arguments=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_array_creation=true
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
cleanup.remove_unused_local_variables=false
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=true
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.simplify_lambda_expression_and_method_ref=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.use_anonymous_class_creation=false
cleanup.use_autoboxing=false
cleanup.use_blocks=false
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_directly_map_method=true
cleanup.use_lambda=true
cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=false
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_this_for_non_static_method_access=false
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup.use_type_arguments=false
cleanup.use_unboxing=false
cleanup.use_var=false
cleanup_profile=_bnd
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_bnd
formatter_settings_version=16
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=java;javax;org;com;
org.eclipse.jdt.ui.javadoc=false
org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.staticondemandthreshold=99
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\n * \n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=true
sp_cleanup.insert_inferred_type_arguments=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_redundant_modifiers=true
sp_cleanup.remove_redundant_semicolons=true
sp_cleanup.remove_redundant_type_arguments=false
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_lambda=true
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
sp_cleanup.use_type_arguments=false
4 changes: 4 additions & 0 deletions biz.aQute.bnd.api/all.bnd
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
Bundle-Description: \
Provides the API for bndlib. It may only contain service APIs or pure libraries \
(no dependencies).

-includepackage biz.aQute.bnd.*.api
6 changes: 6 additions & 0 deletions biz.aQute.bnd.api/facade.bnd
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Bundle-Description: \
Provides the service API specification to create constant objects that get dynamically bound to a \
dynamic backing service when it is present. Primary purpose was to interact with Eclipse Extension \
Points but the idea should work in any environment that is ignorant of dynamics and is oblivious of \
life cycles.

-includepackage biz.aQute.bnd.facade.api
39 changes: 18 additions & 21 deletions biz.aQute.bnd.api/src/biz/aQute/bnd/facade/api/Binder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void setFacadeManager(FacadeManager fm) {
if (fm != null) {
snapshot.forEach(b -> b.register(fm));
} else {
snapshot.forEach(b -> b.release());
snapshot.forEach(Binder::release);
}
}

Expand All @@ -75,7 +75,7 @@ public static void purge() {
/**
* Create a binder and register it locally. If a Facaade Manager is set,
* register there.
*
*
* @param facade
* the object acting as a facade, only a weak
* reference will be maintained
Expand Down Expand Up @@ -152,8 +152,6 @@ public void close() {

/**
* Check if this Binder's facade has been gc'ed.
*
* @return
*/

public boolean hasGone() {
Expand Down Expand Up @@ -234,7 +232,7 @@ public String getDescription() {

/**
* Set the timeout to wait for the backing service to be injected.
*
*
* @param timeout
* timeout in milliseconds
*/
Expand All @@ -260,32 +258,41 @@ public void setState(Object state) {

@Override
public String toString() {
return "Binder[id=" + id + ", description=" + description + "]";
return "Binder[id=" + id + "]";
}

private static void close(AutoCloseable c) {
if (c != null) {
try {
c.close();
} catch (Exception e) {
// ignore
}
}
}

/*
* This adapter is only for test purposes
*/
@SuppressWarnings({ "rawtypes" })
public interface TestAdapter {
public interface TestAdapterNotApiWillChange {

default WeakReference facade(Binder binder) {
default WeakReference<?> facade(Binder<?> binder) {
return binder.facade;
}

default AutoCloseable reg(Binder<?> binder) {
return binder.registration.get();
}

default boolean isClosed(Binder binder) {
default boolean isClosed(Binder<?> binder) {
return binder.closed;
}

default List<Binder<?>> binders() {
return binders;
}

default int cycles(Binder binder) {
default int cycles(Binder<?> binder) {
return binder.cycles;
}

Expand All @@ -294,14 +301,4 @@ default FacadeManager facadeManager() {
}
}

private static void close(AutoCloseable c) {
if (c != null) {
try {
c.close();
} catch (Exception e) {
// ignore
}
}
}

}
4 changes: 2 additions & 2 deletions biz.aQute.bnd.api/src/biz/aQute/bnd/facade/api/Delegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* object. It is associated with a unique ID. There should be only one Delegate
* service with the given id. A Delegate service must be registered with the
* service property {@link FacadeManager#FACADE_ID}
*
*
* @param <D>
* the domain type of the delegate
*/
Expand All @@ -28,7 +28,7 @@ public interface Delegate<D> {
* released, the Facade Manager will ask for its state. The state of the
* previous instance, maybe from a previous delegate or even Facade Manager,
* will be past to this method.
*
*
* @param description
* a description about the caller
* @param state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public interface FacadeManager {
String FACADE_ID = "facade.id";

/**
* Register a binder. For a given binder, this should happen only once per Facade Manager.
*
* Register a binder. For a given binder, this should happen only once per
* registered Facade Manager.
*
* @param binder the binder to register
* @return a closeable that will unregister this binder when closed.
*/
Expand Down
4 changes: 2 additions & 2 deletions biz.aQute.bnd.api/src/biz/aQute/bnd/facade/api/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Represents an instance created by a Delegate. The instance must automatically
* be closed when the Delegate is unregistered.
*
*
* @param <D>
* the type of the domain
*/
Expand All @@ -27,7 +27,7 @@ public interface Instance<D> {

/**
* Close the instance. This will free the backing object. This method can be
* called multiple times.
* called multiple times but will only work the first time.
*/
void close();
}
9 changes: 6 additions & 3 deletions biz.aQute.bnd.api/src/biz/aQute/bnd/facade/api/Memento.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import org.osgi.annotation.versioning.ConsumerType;

/**
* A backing service can have state. When a backing service is unregistered, its
* instance.
* An interface that can optionally be implemented by the backing service. The
* Delegate can use it to get the state when the backing service goes away and
* restore the state when it returns.
* <p>
* The return object must take care not to use domain classes. It should be
* possible to recycle the bundle of the implementation between
Expand All @@ -21,7 +22,9 @@ public interface Memento {

/**
* Set the state of the implementation.
* @param state the given state, retrieved from {@link #getState()} of a previous version
*
* @param state the given state, retrieved from {@link #getState()} of a
* previous version
*/
void setState(Object state);
}
39 changes: 39 additions & 0 deletions biz.aQute.bnd.api/src/biz/aQute/bnd/facade/api/package-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@

@Export
@org.osgi.annotation.versioning.Version("1.0.0")
package biz.aQute.bnd.facade.api;

/**
* The biz.aQute.bnd.facade.api package defines a service for facades. The
* Binder class provides an object that links a facade class to a backing
* service. A facade class is a class that delegates all methods to the Binder,
* each EP type, e.g. IClassPathContainer, has a corresponding facade. E.g.
* IClassPathContainer (see bndtools.facades project).
* <p>
* The facade type and the backing service type might differ. For example, the
* IncrementalProjectBuilder has many final methods. A special interface is
* necessary that passes the IncrementalProjectBuilder as a parameter to the
* methods that the backing service should provide. The Binder object is linked
* via statics (yuck) to a Facade Manager.
* <p>
* The Facade Manager tracks delegate services.A delegate service can either be
* a PROTOTYPE component service or implement the Delegate interface. When there
* is a proper delegate, a Binder is bound to that delegate. Both Binder and
* delegate have a FACADE_ID which is used to line them up. Multiple Binder
* objects can be bound to a single delegate. Each Binder object will be bound
* to a unique instance. The EP defines the name of the class. To define the
* FACADE ID, the class name is appended with a ':' and the facade id. The
* Eclipse Binder class in bndtools.facade project handles the interaction with
* the EP subsystem.
* <p>
* When a Facade Manager is activated, it will set itself as manager in the
* Binder class. This will register each Binder that was created so far and not
* yet purged. When a delegate is registered, the Facade Manager will take care
* that the Binder's with the same type are bound. If the service is
* unregistered, it will unbind the Binder and close the instance. A Binder
* keeps a weak reference to the facade object. If the facade object is garbage
* collected, the Binder should be closed. A periodic task in the Facade Manager
* is responsible for this. When a Binder is unbound, the backing service can
* provide a memento if it implements the Memento interface. When a new instance
* is created, this memento is handed over to the create function in Delegate.
* Clearly this state should not contain references to classes from the backing
* service's bundle since the bundle is likely restarted. However, this allows
* backing services to transfer state between a current instance and a future
* instance.
*/
import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
encoding/bnd.bnd=UTF-8
encoding/launch.bndrun=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
Loading

0 comments on commit 9e4ce34

Please sign in to comment.