Skip to content

Commit

Permalink
Even more compiler warnings fixed:
Browse files Browse the repository at this point in the history
- most of the warnings left are not easily fixed as they would infer major
  changes to our APIs or come from sources we embed.



git-svn-id: https://svn.apache.org/repos/asf/ace/trunk@1727510 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Jan Willem Janssen committed Jan 29, 2016
1 parent 5767e72 commit 3a03379
Show file tree
Hide file tree
Showing 55 changed files with 277 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public class AutoTargetOperator implements ManagedService {
private volatile UserAdmin m_userAdmin;
private volatile BundleContext m_bundleContext;
private volatile LogService m_log;
private volatile Dictionary m_settings;
private volatile Dictionary<String, ?> m_settings;
private volatile ServiceRegistration<Runnable> m_serviceReg;

// used for processing the auditlog (tell the repository about that)
private final AuditLogProcessTask m_task = new AuditLogProcessTask();
private Object m_serviceReg = null;

public void start() {
// get user
Expand All @@ -82,7 +82,7 @@ public void start() {
// start refresh task
Dictionary<String, Object> props = new Hashtable<>();
props.put(SchedulerConstants.SCHEDULER_NAME_KEY, SCHEDULER_NAME);
m_serviceReg = m_bundleContext.registerService(Runnable.class.getName(), m_task, props);
m_serviceReg = m_bundleContext.registerService(Runnable.class, m_task, props);
}
catch (IOException ioe) {
m_log.log(LogService.LOG_ERROR, "Unable to login at repository admin.", ioe);
Expand All @@ -92,7 +92,7 @@ public void start() {
public void stop() {
// service present, pull it
if (m_serviceReg != null) {
((ServiceRegistration) m_serviceReg).unregister();
((ServiceRegistration<?>) m_serviceReg).unregister();
}

m_serviceReg = null;
Expand Down Expand Up @@ -196,7 +196,7 @@ private boolean approveTargets() throws InvalidSyntaxException {
return changed;
}

public void updated(Dictionary settings) throws ConfigurationException {
public void updated(Dictionary<String, ?> settings) throws ConfigurationException {
if (settings != null) {
for (ConfigItem item : ConfigItem.values()) {
String value = (String) settings.get(item.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ public void updated(Dictionary<String, ?> properties) throws ConfigurationExcept
* @param sessionID
* the session ID to use.
*/
@SuppressWarnings("unchecked")
private void createSessionServices(SessionData sd, String sessionID, RepositoryConfiguration repoConfig) {
RepositoryAdminImpl rai = new RepositoryAdminImpl(sessionID, repoConfig);
Component repositoryAdminComponent = createComponent()
Expand All @@ -196,7 +195,7 @@ private void createSessionServices(SessionData sd, String sessionID, RepositoryC
String sessionFilter = "(" + SessionFactory.SERVICE_SID + "=" + sessionID + ")";
String auditLogFilter = "(&(" + Constants.OBJECTCLASS + "=" + LogStore.class.getName() + ")(name=auditlog))";

Dictionary topic = new Hashtable();
Dictionary<String, Object> topic = new Hashtable<>();
topic.put(SessionFactory.SERVICE_SID, sessionID);
topic.put(EventConstants.EVENT_FILTER, sessionFilter);
topic.put(EventConstants.EVENT_TOPIC, new String[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private Properties addSession(Properties props) {
return props;
}

@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void notifyChanged(String topic, Properties props, boolean internalOnly) {
props = addSession(props);
m_eventAdmin.sendEvent(new Event(m_privateTopicRoot + m_entityRoot + topic, (Dictionary) props));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void setBusy(boolean busy) {
writeLock.lock();
try {
for (RepositoryObject o : m_repo) {
((RepositoryObjectImpl) o).setBusy(busy);
((RepositoryObjectImpl<?>) o).setBusy(busy);
}
m_busy = busy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class RepositoryAdminImpl implements RepositoryAdmin {
/**
* Maps from interface classes of the ObjectRepositories to their implementations.
*/
private Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> m_repositories;
private Map<Class<? extends ObjectRepository<?>>, ObjectRepositoryImpl<?, ?>> m_repositories;

private final String m_sessionID;
private final Properties m_sessionProps;
Expand Down Expand Up @@ -165,16 +165,15 @@ public void stop() {
}
}

void initialize(Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> repositories) {
void initialize(Map<Class<? extends ObjectRepository<?>>, ObjectRepositoryImpl<?, ?>> repositories) {
m_repositories = repositories;
}

private ChangeNotifier createChangeNotifier(String topic) {
return m_changeNotifierManager.getConfiguredNotifier(topic, m_sessionID);
}

@SuppressWarnings("unchecked")
private Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> publishRepositories() {
private Map<Class<? extends ObjectRepository<?>>, ObjectRepositoryImpl<?, ?>> publishRepositories() {
// create the repository objects, if this is the first time this method is called. In case a repository
// implementation needs some form of (runtime) configuration, adapt the RepositoryConfiguration object and pass
// this object to the repository...
Expand All @@ -199,7 +198,7 @@ private Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> publishRepo
.add(m_dm.createServiceDependency().setService(LogService.class).setRequired(false))
.add(m_dm.createServiceDependency().setService(ArtifactHelper.class).setRequired(false).setAutoConfig(false).setCallbacks(this, "addArtifactHelper", "removeArtifactHelper"));

Dictionary topic = new Hashtable();
Dictionary<String, Object> topic = new Hashtable<>();
topic.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID + ")");
topic.put(EventConstants.EVENT_TOPIC, new String[] {});

Expand Down Expand Up @@ -227,7 +226,7 @@ private Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> publishRepo
m_services.add(registerRepository(DeploymentVersionRepository.class, m_deploymentVersionRepositoryImpl, new String[] {}));

// prepare the results.
Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> result = new HashMap<>();
Map<Class<? extends ObjectRepository<?>>, ObjectRepositoryImpl<?, ?>> result = new HashMap<>();

result.put(ArtifactRepository.class, m_artifactRepositoryImpl);
result.put(Artifact2FeatureAssociationRepository.class, m_artifact2FeatureAssociationRepositoryImpl);
Expand All @@ -252,13 +251,13 @@ private void pullRepositories() {
}
}

@SuppressWarnings("unchecked")
private <T extends RepositoryObject> Component[] registerRepository(Class<? extends ObjectRepository<T>> iface, ObjectRepositoryImpl<?, T> implementation, String[] topics) {
Component repositoryService = m_dm.createComponent()
.setInterface(iface.getName(), m_sessionProps)
.setImplementation(implementation)
.add(m_dm.createServiceDependency().setService(LogService.class).setRequired(false));
Dictionary topic = new Hashtable();

Dictionary<String, Object> topic = new Hashtable<>();
topic.put(EventConstants.EVENT_TOPIC, topics);
topic.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID + ")");
Component handlerService = m_dm.createComponent()
Expand Down Expand Up @@ -475,7 +474,7 @@ private RepositorySet[] getRepositorySets(RepositoryAdminLoginContextImpl contex

// First, some sanity checks on the list of descriptors.
for (RepositorySetDescriptor rsd : descriptors) {
for (Class c : rsd.m_objectRepositories) {
for (Class<?> c : rsd.m_objectRepositories) {
// Do we have an impl for each repository class?
if (!m_repositories.containsKey(c)) {
throw new IllegalArgumentException(rsd.toString() + " references repository class " + c.getName() + " for which no implementation is available.");
Expand All @@ -491,7 +490,7 @@ private RepositorySet[] getRepositorySets(RepositoryAdminLoginContextImpl contex
for (int i = 0; i < result.length; i++) {
RepositorySetDescriptor rsd = descriptors.get(i);

ObjectRepositoryImpl[] impls = new ObjectRepositoryImpl[rsd.m_objectRepositories.length];
ObjectRepositoryImpl<?, ?>[] impls = new ObjectRepositoryImpl[rsd.m_objectRepositories.length];
String[] topics = new String[rsd.m_objectRepositories.length];
for (int j = 0; j < impls.length; j++) {
impls[j] = m_repositories.get(rsd.m_objectRepositories[j]);
Expand Down Expand Up @@ -585,7 +584,7 @@ private CachedRepository getCachedRepositoryFromPreferences(Repository repositor
* @return The newly created repository set.
* @throws IOException
*/
public RepositorySet loadRepositorySet(User user, RepositorySetDescriptor rsd, ObjectRepositoryImpl[] repos) throws IOException {
public RepositorySet loadRepositorySet(User user, RepositorySetDescriptor rsd, ObjectRepositoryImpl<?, ?>[] repos) throws IOException {
Repository repo = new RemoteRepository(rsd.m_location, rsd.m_customer, rsd.m_name);

// Expose the repository itself as component so its dependencies get managed...
Expand Down Expand Up @@ -630,12 +629,12 @@ public WorkingState getWorkingState(RepositoryObject object) {
return (result == null) ? WorkingState.Unchanged : result;
}

public void addArtifactHelper(ServiceReference ref, ArtifactHelper helper) {
public void addArtifactHelper(ServiceReference<ArtifactHelper> ref, ArtifactHelper helper) {
String mimetype = (String) ref.getProperty(ArtifactHelper.KEY_MIMETYPE);
m_artifactRepositoryImpl.addHelper(mimetype, helper);
}

public synchronized void removeArtifactHelper(ServiceReference ref, ArtifactHelper helper) {
public synchronized void removeArtifactHelper(ServiceReference<ArtifactHelper> ref, ArtifactHelper helper) {
String mimetype = (String) ref.getProperty(ArtifactHelper.KEY_MIMETYPE);
m_artifactRepositoryImpl.removeHelper(mimetype, helper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ String getSessionId() {
* the to-be-added repository set descriptor, cannot be <code>null</code>.
*/
private void checkConsistency(RepositorySetDescriptor descriptor) {
List<Class<? extends ObjectRepository>> seenClasses = new ArrayList<>();
List<Class<? extends ObjectRepository<?>>> seenClasses = new ArrayList<>();
List<String> seenNames = new ArrayList<>();

// Presumption: initially we start out without any duplication...
Expand All @@ -132,7 +132,7 @@ private void checkConsistency(RepositorySetDescriptor descriptor) {
throw new IllegalArgumentException("Duplicate repository name!");
}

for (Class<? extends ObjectRepository> clazz : descriptor.m_objectRepositories) {
for (Class<? extends ObjectRepository<?>> clazz : descriptor.m_objectRepositories) {
if (seenClasses.contains(clazz)) {
throw new IllegalArgumentException("Duplicate object repository!");
}
Expand All @@ -148,9 +148,9 @@ public static final class RepositorySetDescriptor {
public final String m_customer;
public final String m_name;
public final boolean m_writeAccess;
public final Class<? extends ObjectRepository>[] m_objectRepositories;
public final Class<? extends ObjectRepository<?>>[] m_objectRepositories;

public RepositorySetDescriptor(URL location, String customer, String name, boolean writeAccess, Class<? extends ObjectRepository>... objectRepositories) {
public RepositorySetDescriptor(URL location, String customer, String name, boolean writeAccess, Class<? extends ObjectRepository<?>>... objectRepositories) {
m_location = location;
m_customer = customer;
m_name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
* <code>put()</code> and <code>remove()</code>. It 'looks' like a dictionary to allow filtering of it, using an ldap
* filter.
*/
@SuppressWarnings("rawtypes")
public class RepositoryObjectImpl<T extends RepositoryObject> extends Dictionary<String, Object> implements RepositoryObject, EventHandler {
private final Map<String, String> m_attributes = new HashMap<>();
private final Map<String, String> m_tags = new HashMap<>();
/** see ACE-463 */
private final Set<String> m_mergedAttrTags = new HashSet<>();
private final Map<Class, List<Association>> m_associations = new HashMap<>();
private final Map<Class<?>, List<Association>> m_associations = new HashMap<>();
private final ChangeNotifier m_notifier;
private final String m_xmlNode;
private static final Pattern VALID_KEY_PATTERN = Pattern.compile("[a-zA-Z]([a-zA-Z0-9_:.-])*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
* xstream's writer in a delegate object, so this will not require changes to the repositories and objects.
*/
class RepositorySerializer implements Converter {
private final Map<String, ObjectRepositoryImpl> m_tagToRepo = new HashMap<>();
private final Map<String, ObjectRepositoryImpl<?, ?>> m_tagToRepo = new HashMap<>();

private final RepositorySet m_set;

private final XStream m_stream;

RepositorySerializer(RepositorySet set) {
m_set = set;
for (ObjectRepositoryImpl repo : m_set.getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : m_set.getRepos()) {
m_tagToRepo.put(repo.getXmlNode(), repo);
}
m_stream = new XStream();
Expand All @@ -56,7 +56,7 @@ class RepositorySerializer implements Converter {
}

public void marshal(Object target, HierarchicalStreamWriter writer, MarshallingContext context) {
for (ObjectRepositoryImpl repo : m_set.getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : m_set.getRepos()) {
repo.marshal(writer);
}
}
Expand All @@ -65,7 +65,7 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co
while (reader.hasMoreChildren()) {
reader.moveDown();
String nodeName = reader.getNodeName();
ObjectRepositoryImpl o = m_tagToRepo.get(nodeName);
ObjectRepositoryImpl<?, ?> o = m_tagToRepo.get(nodeName);
o.unmarshal(reader);
reader.moveUp();
}
Expand All @@ -77,7 +77,7 @@ public boolean canConvert(Class target) {
}

public void toXML(OutputStream out) throws IOException {
for (ObjectRepositoryImpl repo : m_set.getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : m_set.getRepos()) {
repo.setBusy(true);
}
try {
Expand All @@ -87,7 +87,7 @@ public void toXML(OutputStream out) throws IOException {
}
finally {
// Ensure all busy flags are reset at all times...
for (ObjectRepositoryImpl repo : m_set.getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : m_set.getRepos()) {
repo.setBusy(false);
}
}
Expand All @@ -102,7 +102,7 @@ public void toXML(OutputStream out) throws IOException {
public void fromXML(InputStream in) {
// The repositories get cleared, since a user *could* add stuff before
// checking out.
for (ObjectRepositoryImpl repo : m_set.getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : m_set.getRepos()) {
repo.setBusy(true);
repo.removeAll();
}
Expand All @@ -122,7 +122,7 @@ public void fromXML(InputStream in) {
finally {
Thread.currentThread().setContextClassLoader(cl);
// Ensure all busy flags are reset at all times...
for (ObjectRepositoryImpl repo : m_set.getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : m_set.getRepos()) {
repo.setBusy(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ class RepositorySet {

private final User m_user;
private final Preferences m_prefs;
private final ObjectRepositoryImpl[] m_repos;
private final ObjectRepositoryImpl<?, ?>[] m_repos;
private final CachedRepository m_repository;
private final String m_name;
private final boolean m_writeAccess;
private final ConcurrentMap<RepositoryObject, WorkingState> m_workingState;
private final ChangeNotifier m_notifier;
private final LogService m_log;

private volatile ServiceRegistration m_modifiedHandler;
private volatile ServiceRegistration<EventHandler> m_modifiedHandler;

/* ********
* Basics
Expand All @@ -80,7 +80,7 @@ class RepositorySet {
* that endpoints of an association are available at the time of deserialization.</li>
* </ul>
*/
RepositorySet(ChangeNotifier notifier, LogService log, User user, Preferences prefs, ObjectRepositoryImpl[] repos, CachedRepository repository, String name, boolean writeAccess) {
RepositorySet(ChangeNotifier notifier, LogService log, User user, Preferences prefs, ObjectRepositoryImpl<?, ?>[] repos, CachedRepository repository, String name, boolean writeAccess) {
m_workingState = new ConcurrentHashMap<>();
m_notifier = notifier;
m_log = log;
Expand Down Expand Up @@ -114,7 +114,7 @@ User getUser() {
return m_user;
}

ObjectRepositoryImpl[] getRepos() {
ObjectRepositoryImpl<?, ?>[] getRepos() {
return m_repos;
}

Expand Down Expand Up @@ -148,7 +148,6 @@ void savePreferences() {
/**
* Only call this after the repository has been deserialized.
*/
@SuppressWarnings("unchecked")
void loadPreferences() {
Preferences workingNode = m_prefs.node(PREFS_LOCAL_WORKING_STATE);
Map<String, WorkingState> entries = new HashMap<>();
Expand All @@ -168,7 +167,7 @@ void loadPreferences() {
}
// Then, go through all objects and check whether they match a definition we know.
// This prevents calling getDefinition more than once per object.
for (ObjectRepository<RepositoryObject> repo : m_repos) {
for (ObjectRepository<?> repo : m_repos) {
for (RepositoryObject o : repo.get()) {
WorkingState state = entries.get(o.getDefinition());
if (state != null) {
Expand Down Expand Up @@ -246,18 +245,18 @@ boolean isCurrent() throws IOException {
}

void clearRepositories() {
for (ObjectRepositoryImpl repo : getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : getRepos()) {
repo.setBusy(true);
}

try {
for (ObjectRepositoryImpl repo : getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : getRepos()) {
repo.removeAll();
}
}
finally {
// Ensure all busy flags are reset at all times...
for (ObjectRepositoryImpl repo : getRepos()) {
for (ObjectRepositoryImpl<?, ?> repo : getRepos()) {
repo.setBusy(false);
}
}
Expand All @@ -284,7 +283,7 @@ void registerHandler(BundleContext context, String sessionID, String... topics)
Dictionary<String, Object> topic = new Hashtable<>();
topic.put(EventConstants.EVENT_TOPIC, topics);
topic.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + sessionID + ")");
m_modifiedHandler = context.registerService(EventHandler.class.getName(), new ModifiedHandler(), topic);
m_modifiedHandler = context.registerService(EventHandler.class, new ModifiedHandler(), topic);
}

WorkingState getWorkingState(RepositoryObject object) {
Expand All @@ -301,7 +300,6 @@ int getNumberWithWorkingState(Class<? extends RepositoryObject> clazz, WorkingSt
return result;
}

@SuppressWarnings("unchecked")
private void resetModified(boolean fill) {
m_workingState.clear();
if (fill) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ public <T extends Associatable> List<T> getAssociations(Class<T> clazz) {
}
}

@SuppressWarnings("rawtypes")
public <T extends Associatable, A extends Association> List<A> getAssociationsWith(Associatable other, Class<T> clazz, Class<A> associationType) {
synchronized (m_lock) {
ensureTargetPresent();
Expand Down
Loading

0 comments on commit 3a03379

Please sign in to comment.